package com.ad.pet.app;

import android.app.Activity;
import android.content.Context;
import android.content.Intent;
import android.provider.ContactsContract;
import android.support.v4.app.Fragment;
import android.support.v4.app.FragmentActivity;

import com.ad.pet.MainActivity;
import com.ad.pet.app.account.AboutUsActivity;
import com.ad.pet.app.account.CollectionSelectorActivity;
import com.ad.pet.app.account.CommonWebActitivity;
import com.ad.pet.app.account.HelpCenterAcitivity;
import com.ad.pet.app.account.SuggestFadeActivity;
import com.ad.pet.app.account.info.PersonBaseInfoActivity;
import com.ad.pet.app.account.info.PetInfoActivity;
import com.ad.pet.app.account.order.ConfirmOrderActivity;
import com.ad.pet.app.account.order.DoorServiceOrderActivity;
import com.ad.pet.app.account.order.MallServiceActivity;
import com.ad.pet.app.account.order.MyOrderServiceActivity;
import com.ad.pet.app.account.order.OrderSelectActivity;
import com.ad.pet.app.account.order.OrderServiceActivity;
import com.ad.pet.app.account.order.OrderStatusActivity;
import com.ad.pet.app.account.order.PacketDetailActivity;
import com.ad.pet.app.account.order.ServiceOrderDetailActivity;
import com.ad.pet.app.account.order.ServleceCollectionActivity;
import com.ad.pet.app.account.record.AccountRecordActivity;
import com.ad.pet.app.account.record.PointDetailActivity;
import com.ad.pet.app.account.record.ReviewRecordListActivity;
import com.ad.pet.app.account.record.YueDetailActvity;
import com.ad.pet.app.account.share.ShareRecordActivity;
import com.ad.pet.app.address.AddressDetailActivity;
import com.ad.pet.app.address.AddressListActivity;
import com.ad.pet.app.collect.ArticleCollectionActivity;
import com.ad.pet.app.collect.CollectActivity;
import com.ad.pet.app.login.ChoseCountryActivity;
import com.ad.pet.app.login.ForgetPwdActivity;
import com.ad.pet.app.login.MobileInputActivity;
import com.ad.pet.app.login.MobileRegistActivity;
import com.ad.pet.app.login.ResetPwdActivity;
import com.ad.pet.app.login.ThirdBindActivity;
import com.ad.pet.app.main.concer.PetConcerListActivity;
import com.ad.pet.app.main.desniger.DesnigerStoreActivity;
import com.ad.pet.app.main.desniger.DesnigerStoreListActivity;
import com.ad.pet.app.mall.ChoseCounpousActivity;
import com.ad.pet.app.mall.DoorOrderActivity;
import com.ad.pet.app.mall.FlashBuyActivity;
import com.ad.pet.app.mall.GoodDetailActivity;
import com.ad.pet.app.mall.GoodRateListActivity;
import com.ad.pet.app.mall.GoodRecordListActivity;
import com.ad.pet.app.mall.ServiceDetailActivity;
import com.ad.pet.app.photo.PhotoMaxListActivity;
import com.ad.pet.app.photo.PhotoMaxListSelectActivity;
import com.ad.pet.app.photo.loader.ui.PhotoLoaderActivity;
import com.ad.pet.app.photo.model.ImageItem;
import com.ad.pet.app.photo.model.PhotoItem;
import com.ad.pet.app.recharge.CashMoneyActivity;
import com.ad.pet.app.recharge.RechargeActvity;
import com.ad.pet.app.serach.SerachEndActivity;
import com.ad.pet.app.serach.SerachHistoryActivity;
import com.ad.pet.app.shopcar.confirm.CompleteOrderActivity;
import com.ad.pet.app.shopcar.confirm.ConfirmStyleOrderActivity;
import com.ad.pet.app.shopcar.confirm.PayWebViewActivity;
import com.ad.pet.app.splash.SplashActivity;
import com.ad.pet.app.splash.WelcomeActivity;
import com.ad.pet.app.upgrade.UpgradeActivity;
import com.ad.pet.common.structure.ui.activity.BaseActivity;
import com.ad.pet.constant.AppStatusConstant;
import com.ad.pet.constant.Constant;
import com.ad.pet.message.MessageActivity;
import com.ad.pet.message.OrderMessageActivity;
import com.ad.pet.message.SaleMessageActivity;
import com.ad.pet.message.SystemMessageActivity;
import com.ad.pet.message.record.BuinessRecordDetailActivity;
import com.ad.pet.message.record.BuinessRecordListActivity;
import com.ad.pet.models.remote.CommList;
import com.ad.pet.models.remote.account.Account;
import com.ad.pet.models.remote.account.order.OrderType;
import com.ad.pet.models.remote.address.Address;
import com.ad.pet.models.remote.cart.Good;
import com.ad.pet.models.remote.main.DesingerMain;
import com.ad.pet.models.remote.main.DesingerStore;
import com.ad.pet.models.remote.mall.ChoseOrder;
import com.ad.pet.models.remote.message.Record;

import java.util.ArrayList;
import java.util.List;

/**
 * Created by z on.
 * Des:页面导航类
 * Date: 2017/3/8
 */

public class Navigation {


    public static void goMainActivity(Activity activity) {
        Intent intent = new Intent(activity, MainActivity.class);
        intent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP | Intent.FLAG_ACTIVITY_NEW_TASK);
        activity.startActivity(intent);
    }
    public static void goMainActivity(Context activity) {
        Intent intent = new Intent(activity, MainActivity.class);
        intent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP | Intent.FLAG_ACTIVITY_NEW_TASK);
        activity.startActivity(intent);
    }
    public static void freshView(Activity activity) {
        Intent intent = new Intent(activity, MainActivity.class);
        intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK | Intent.FLAG_ACTIVITY_CLEAR_TASK);
        activity.startActivity(intent);

    }


    public static void goPhotoMaxListActivity(Activity activity, ArrayList<PhotoItem> photoItems, int currentPosition) {
        Intent intent = new Intent(activity, PhotoMaxListActivity.class);
        intent.putExtra("photos", photoItems);
        intent.putExtra("currentPosition", currentPosition);
        activity.startActivity(intent);
    }


    public static void goPhotoMaxListSelectActivity(Fragment fragment, ArrayList<ImageItem> photoItems, int currentPosition, int selectedMax) {
        Intent intent = new Intent(fragment.getActivity(), PhotoMaxListSelectActivity.class);
        intent.putExtra("photos", photoItems);
        intent.putExtra("currentPosition", currentPosition);
        intent.putExtra("selectedMax", selectedMax);
        fragment.startActivityForResult(intent, 1001);
    }


    public static void goPhotoLoaderActivity(Activity activity, int code, int maxValue) {
        Intent intent = new Intent(activity, PhotoLoaderActivity.class);
        intent.putExtra("selectedMax", maxValue);
        activity.startActivityForResult(intent, code);
    }

    public static void goPhotoLoaderActivity(Fragment fragment, int code, int maxValue) {
        Intent intent = new Intent(fragment.getActivity(), PhotoLoaderActivity.class);
        intent.putExtra("selectedMax", maxValue);
        fragment.startActivityForResult(intent, code);
    }

//    public static void goMobileInput(Activity mainActivity) {
//        Intent intent = new Intent(mainActivity, MobileInputActivity.class);
//        mainActivity.startActivityForResult(intent, 0);
//    }
//    public static void goMobileInput(Activity mainActivity,String type,String value,String name) {
//        Intent intent = new Intent(mainActivity, MobileInputActivity.class);
//        intent.putExtra(Constant.THIRD_PARTY,type);
//        intent.putExtra(Constant.THIRD_VALUE,value);
//        intent.putExtra(Constant.THIRD_NAME,name);
//        mainActivity.startActivityForResult(intent, 0);
//    }


    public static void goChoseCountry(Activity activity, int code) {
        Intent intent = new Intent(activity, ChoseCountryActivity.class);
        activity.startActivityForResult(intent, code);
    }

    public static void goLogin(Activity activity, int code, int type) {
        Intent intent = new Intent(activity, MobileInputActivity.class);
        intent.putExtra("type", type);
        activity.startActivityForResult(intent, code);
    }
    public static void goLogin(Context activity) {
        Intent intent = new Intent(activity, MobileInputActivity.class);
        intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
        activity.startActivity(intent);
    }
    public static void goForgetPwd(Activity activity) {
        Intent intent = new Intent(activity, ForgetPwdActivity.class);
        activity.startActivity(intent);
    }

    public static void goThirdBind(Activity activity, String thirdId, String imgUrl, String nickName, String uniqueId) {
        Intent intent = new Intent(activity, ThirdBindActivity.class);
        intent.putExtra("Third_id", thirdId);
        intent.putExtra("image_url", imgUrl);
        intent.putExtra("nickname", nickName);
        intent.putExtra("uniqueId", uniqueId);
        activity.startActivityForResult(intent, MainActivity.REQUEST_GO_MALL);
    }


    public static void goGoodDetail(Activity activity, int code, String productId) {
        Intent intent = new Intent(activity, GoodDetailActivity.class);
        intent.putExtra(Constant.PRODUCT_ID, productId);
        activity.startActivityForResult(intent, code);
    }


    public static void goSerachHirstory(Activity activity, int code) {
        Intent intent = new Intent(activity, SerachHistoryActivity.class);

//        intent.putExtra("keyword",keyword);
        activity.startActivityForResult(intent, code);
    }


    public static void goSerachEnd(Activity activity, String keyword, int code, String id, String is_home_cate) {
        Intent intent = new Intent(activity, SerachEndActivity.class);
        intent.putExtra("keyword", keyword);
        intent.putExtra(Constant.IS_MAIN, is_home_cate);
        intent.putExtra(Constant.CATEGROY_ID, id);
        activity.startActivityForResult(intent, code);
    }

    /**
     * 普通的跳转网页一般用这个
     *
     * @param activity
     * @param title
     * @param url
     * @param isFinish
     * @param code
     */
    public static void goCommonWebView(Activity activity, String title, String url, boolean isFinish, int code) {
        Intent intent = new Intent(activity, CommonWebActitivity.class);
        intent.putExtra("title", title);
        intent.putExtra("url", url);
        intent.putExtra("isFinish", isFinish);
        activity.startActivityForResult(intent, code);
    }

    public static void goCommonWebView(Activity activity, String title, String url, boolean isFinish, boolean isShow, int code) {
        Intent intent = new Intent(activity, CommonWebActitivity.class);
        intent.putExtra("title", title);
        intent.putExtra("url", url);
        intent.putExtra("isShow", isShow);
        intent.putExtra("isFinish", isFinish);
        activity.startActivityForResult(intent, code);
    }


    /**
     * 如果url不需要返回的话可以用这个
     *
     * @param activity
     * @param title
     * @param url
     * @param isFinish
     */
    public static void goCommonWebView(Activity activity, String title, String url, boolean isFinish) {
        Intent intent = new Intent(activity, CommonWebActitivity.class);
        intent.putExtra("title", title);
        intent.putExtra("url", url);
        intent.putExtra("isFinish", isFinish);
        activity.startActivity(intent);
    }

    /**
     * 推送用来点击跳转用的
     *
     * @param activity
     * @param title
     * @param url
     */
    public static void goCommonWebView(Context activity, String title, String url) {
        Intent intent = new Intent(activity, CommonWebActitivity.class);
        intent.putExtra("title", title);
        intent.putExtra("url", url);
        intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
        activity.startActivity(intent);
    }

    public static void goUpgradeActivity(Activity activity, boolean isFinish, String url) {
        Intent intent = new Intent(activity, UpgradeActivity.class);
        intent.putExtra("isFinish", isFinish);
        intent.putExtra("url", url);
        activity.startActivity(intent);
    }


    public static void restartApp(Activity activity) {
        Intent intent = new Intent(activity, MainActivity.class);
        intent.putExtra(AppStatusConstant.KEY_HOME_ACTION, AppStatusConstant.ACTION_RESTART_APP);
        activity.startActivity(intent);

    }

    public static void goWelcome(Activity activity) {
        activity.startActivity(new Intent(activity, WelcomeActivity.class));
        activity.finish();
    }


    public static void goSplashActivity(Activity activity) {
        Intent intent = new Intent(activity, SplashActivity.class);
        activity.startActivity(intent);
    }


    public static void goRecharge(FragmentActivity context, String order_sn, int code) {
        Intent intent = new Intent(context, RechargeActvity.class);
        intent.putExtra(Constant.ORDER_SN, order_sn);
        context.startActivityForResult(intent, code);
    }


    public static void goContractBook(Activity activity, int code) {
        Intent i = new Intent();
        i.setAction(Intent.ACTION_PICK);
        i.setData(ContactsContract.Contacts.CONTENT_URI);
        activity.startActivityForResult(i, 1);
    }


    public static void goAddress(Activity context, Address address, boolean isCheck, int code) {
        Intent intent = new Intent(context, AddressListActivity.class);
        intent.putExtra("address", address);
        intent.putExtra(Constant.IS_CHECK, isCheck);
        context.startActivityForResult(intent, code);
    }


    public static void goAddressDetail(BaseActivity activity, Address address, int i, boolean ischeck) {
        Intent intent = new Intent(activity, AddressDetailActivity.class);
        intent.putExtra("address", address);
        intent.putExtra(Constant.IS_CHECK, ischeck);
        activity.startActivityForResult(intent, i);
    }

    public static void goCollectin(Activity context, int code) {
        Intent intent = new Intent(context, CollectActivity.class);
        context.startActivityForResult(intent, code);
    }

    public static void goCollectin(Context context) {
        Intent intent = new Intent(context, CollectActivity.class);
        context.startActivity(intent);
    }

    public static void goPersonBaseInfo(Activity activity, Account account, int code) {
        Intent intent = new Intent(activity, PersonBaseInfoActivity.class);
        intent.putExtra("account", account);
        activity.startActivityForResult(intent, code);
    }

    public static void goPetInfo(Activity activity, String id) {
        Intent intent = new Intent(activity, PetInfoActivity.class);
        intent.putExtra("id", id);
        activity.startActivity(intent);
    }

    public static void goOrderSeletc(Activity activity) {
        Intent intent = new Intent(activity, OrderSelectActivity.class);
        activity.startActivity(intent);
    }

    public static void goConfirmStyleOrder(Activity activity, String cartIds, String price, List<Good> goods, CommList commList, int code) {
        Intent intent = new Intent(activity, ConfirmStyleOrderActivity.class);
        intent.putExtra(Constant.CART_IDS, cartIds);
        intent.putExtra(Constant.CART_ID, (ArrayList<Good>) goods);
        intent.putExtra(Constant.NAME, commList);
        intent.putExtra(Constant.START_PRICE, price);

        activity.startActivityForResult(intent, code);
    }


    public static void goMobileRegist(Fragment activity, int i, int flag) {
        Intent intent = new Intent(activity.getActivity(), MobileRegistActivity.class);
        intent.putExtra("type", i);
        activity.startActivityForResult(intent, flag);
    }


    public static void goOrderStatus(BaseActivity activity, String type, String name) {
        Intent intent = new Intent(activity, OrderStatusActivity.class);
        intent.putExtra(Constant.STATUS, type);
        intent.putExtra(Constant.NAME, name);
        activity.startActivityForResult(intent, MainActivity.REQUEST_GO_MALL);

    }

    public static void goPacketDetail(FragmentActivity activity, String pgId) {
        Intent intent = new Intent(activity, PacketDetailActivity.class);
        intent.putExtra(Constant.PG_ID, pgId);
        activity.startActivity(intent);
    }

    public static void goGoodRateList(BaseActivity activity, String pid) {
        Intent intent = new Intent(activity, GoodRateListActivity.class);
        intent.putExtra(Constant.PRODUCT_ID, pid);
        activity.startActivity(intent);
    }

    public static void goCompleteOrder(BaseActivity activity, String ordersn) {
        Intent intent = new Intent(activity, CompleteOrderActivity.class);
        intent.putExtra(Constant.ORDER_SN, ordersn);
        intent.setFlags(Intent.FLAG_ACTIVITY_REORDER_TO_FRONT);
        activity.startActivityForResult(intent, MainActivity.REQUEST_GO_MALL);
    }


    public static void goConfirmOrder(FragmentActivity activity, OrderType orderType) {
        Intent intent = new Intent(activity, ConfirmOrderActivity.class);
        intent.putExtra(Constant.ORDER_PRODUCT_ID, orderType);
        activity.startActivityForResult(intent, MainActivity.REQUEST_GO_MALL);
    }

    public static void goResetPwd(FragmentActivity activity) {
        Intent intent = new Intent(activity, ResetPwdActivity.class);
        activity.startActivityForResult(intent, MainActivity.REQUEST_GO_MALL);
    }

    public static void goPayWebView(FragmentActivity activity, String url, String sns) {
        Intent intent = new Intent(activity, PayWebViewActivity.class);
        intent.putExtra(Constant.NAME, url);
        intent.putExtra(Constant.ORDER_SN, sns);
        activity.startActivityForResult(intent, MainActivity.REQUEST_GO_MALL);
    }

    public static void goRecordList(BaseActivity activity, String productId) {
        Intent intent = new Intent(activity, GoodRecordListActivity.class);
        intent.putExtra(Constant.PRODUCT_ID, productId);
        activity.startActivity(intent);
    }

    public static void goHelpCenter(FragmentActivity activity) {

        Intent intent = new Intent(activity, HelpCenterAcitivity.class);

        activity.startActivityForResult(intent, MainActivity.REQUEST_GO_MALL);
    }

    public static void goCashMoney(FragmentActivity activity) {
        Intent intent = new Intent(activity, CashMoneyActivity.class);
        activity.startActivity(intent);
    }


    public static void goMessageActivity(FragmentActivity activity, int code) {

        Intent intent = new Intent(activity, MessageActivity.class);
        activity.startActivityForResult(intent, code);

    }

    public static void goMessageActivity(Context activity) {

        Intent intent = new Intent(activity, MessageActivity.class);
        activity.startActivity(intent);

    }

    public static void goOrderMessage(BaseActivity activity, String cid, int code) {
        Intent intent = new Intent(activity, OrderMessageActivity.class);
        intent.putExtra(Constant.C_ID, cid);
        activity.startActivityForResult(intent, code);
    }

    public static void goSystemMessage(BaseActivity activity, String cid, int code) {
        Intent intent = new Intent(activity, SystemMessageActivity.class);
        intent.putExtra(Constant.C_ID, cid);
        activity.startActivityForResult(intent, code);
    }

    public static void goSaleMessage(BaseActivity activity, String cid, int code) {
        Intent intent = new Intent(activity, SaleMessageActivity.class);
        intent.putExtra(Constant.C_ID, cid);
        activity.startActivityForResult(intent, code);
    }


    public static void goDesignerStore(Activity activity, DesingerMain desingerMain) {

        Intent intent = new Intent(activity, DesnigerStoreActivity.class);
        intent.putExtra("store", desingerMain);
        activity.startActivity(intent);
    }



    public static void goDesignerStoreList(Fragment activity, DesingerStore desingerStore, String myLongTiue, String myLanTiue) {
        Intent intent = new Intent(activity.getActivity(), DesnigerStoreListActivity.class);
        intent.putExtra("Store", desingerStore);
        intent.putExtra("long", myLongTiue);
        intent.putExtra("lan", myLanTiue);
        activity.startActivityForResult(intent, 100);
    }


    public static void goRecord(Activity a, Record record) {
        Intent intent = new Intent(a, BuinessRecordDetailActivity.class);
        intent.putExtra(Constant.NAME, record);
        a.startActivity(intent);
    }

    public static void goRecordList(Context a) {
        Intent intent = new Intent(a, BuinessRecordListActivity.class);
        a.startActivity(intent);
    }


    public static void goFlashGood(FragmentActivity activity) {
        Intent intent = new Intent(activity, FlashBuyActivity.class);
        activity.startActivityForResult(intent, MainActivity.REQUEST_GO_MALL);
    }

    public static void goRecordAccount(FragmentActivity activity) {
        Intent intent = new Intent(activity, AccountRecordActivity.class);
        activity.startActivityForResult(intent, MainActivity.REQUEST_GO_MALL);
    }

    public static void goShareRecord(BaseActivity mActivity) {
        Intent intent = new Intent(mActivity, ShareRecordActivity.class);
        mActivity.startActivityForResult(intent, MainActivity.REQUEST_GO_MALL);
    }

    public static void goReviewRecordList(FragmentActivity activity) {
        Intent intent = new Intent(activity, ReviewRecordListActivity.class);
        activity.startActivityForResult(intent, MainActivity.REQUEST_GO_MALL);
    }

    public static void goAboutUs(BaseActivity mActivity) {
        Intent intent = new Intent(mActivity, AboutUsActivity.class);
        mActivity.startActivityForResult(intent, MainActivity.REQUEST_GO_MALL);
    }

    public static void goSuggestFade(FragmentActivity baseActivity) {
        Intent intent = new Intent(baseActivity, SuggestFadeActivity.class);
        baseActivity.startActivity(intent);
    }

    public static void goCollectionSelect(FragmentActivity activity) {
        Intent intent = new Intent(activity, CollectionSelectorActivity.class);
        activity.startActivity(intent);
    }

    public static void goDoorOrderService(Activity activity) {
        Intent intent = new Intent(activity, DoorServiceOrderActivity.class);
        activity.startActivity(intent);
    }

    public static void goOrderService(Activity activity) {
        Intent intent = new Intent(activity, OrderServiceActivity.class);
        activity.startActivity(intent);
    }

    public static void goMallService(Activity activity) {
        Intent intent = new Intent(activity, MallServiceActivity.class);
        activity.startActivity(intent);
    }

    public static void goMyOrderService(Activity activity) {
        Intent intent = new Intent(activity, MyOrderServiceActivity.class);
        activity.startActivity(intent);
    }

    public static void goAritcleCollection(BaseActivity mActivity) {
        Intent intent = new Intent(mActivity, ArticleCollectionActivity.class);
        mActivity.startActivity(intent);
    }

    public static void goServiceCollecion(BaseActivity mActivity) {
        Intent intent = new Intent(mActivity, ServleceCollectionActivity.class);
        mActivity.startActivity(intent);
    }

    public static void goServiceDetail(Activity activity, String oid, String sid,String shop_name) {
        Intent intent = new Intent(activity, ServiceDetailActivity.class);
        intent.putExtra(Constant.ORDER_ID, oid);
        intent.putExtra(Constant.SHIPPING_ID, sid);
        intent.putExtra("shop_name",shop_name);
        activity.startActivity(intent);
    }

    public static void goDoorOrder(Activity serviceDetailActivity, ChoseOrder order) {
        Intent intent = new Intent(serviceDetailActivity, DoorOrderActivity.class);
        intent.putExtra("order",order);
        serviceDetailActivity.startActivity(intent);
    }

    public static void goPetConcer(Activity activity, DesingerStore desingerStore, String myLongTiue, String myLanTiue) {
        Intent intent = new Intent(activity, PetConcerListActivity.class);
        intent.putExtra("Store", desingerStore);
        intent.putExtra("long", myLongTiue);
        intent.putExtra("lan", myLanTiue);
        activity.startActivityForResult(intent, 100);
    }

    public static void goServiceOrderDetail(Activity activity,String orderId) {
        Intent intent = new Intent(activity, ServiceOrderDetailActivity.class);
        intent.putExtra("orderid",orderId);
        activity.startActivity(intent);
    }

    public static void goChoseCounpus(Activity activity,String oid,String week) {
        Intent intent = new Intent(activity, ChoseCounpousActivity.class);
        intent.putExtra("state",oid);
        intent.putExtra("week",week);
        activity.startActivityForResult(intent,211);
    }

    public static void goPointDetail(FragmentActivity activity) {
        Intent intent = new Intent(activity, PointDetailActivity.class);
        activity.startActivity(intent);
    }
    public static void getYueDetail(FragmentActivity activity) {
        Intent intent = new Intent(activity, YueDetailActvity.class);
        activity.startActivity(intent);
    }
}
